<jsp:directive.include file="/WEB-INF/view/jsp/passport/ui/includes/top.jsp" />

<%@ page import="org.jasig.cas.web.support.WebUtils"%>
<%@ page import="org.springframework.security.web.WebAttributes"%>

<div id="pg-login">
	<div class="container_12" style="min-height:400px;">
		<div id="msg" class="errors" style="margin-left:20px; margin-right:20px;">
			<h2><spring:message code="screen.blocked.header" /></h2>
			<%
		        // Look for details of authorization failure in well-known request attributes.
		        final String[] keys = new String[] {WebUtils.CAS_ACCESS_DENIED_REASON, WebAttributes.AUTHENTICATION_EXCEPTION};
		        Object detail = null;
		        for (String key : keys) {
		            detail = request.getAttribute(key);
		            if (detail == null) {
		                detail = request.getSession().getAttribute(key);
		                request.getSession().removeAttribute(key);
		            }
		            if (detail != null) {
		                break;
		            }
		        }
		        if (detail instanceof String) {
		            request.setAttribute("messageKey", detail);
		        } else if (detail instanceof Exception) {
		            final Exception cause = (Exception) detail;
		            final String message = String.format("%s::%s", cause.getClass().getSimpleName(), cause.getMessage());
		            request.setAttribute("message", message);
		        }
		    %>
		    <c:choose>
		        <c:when test="${not empty messageKey}">
		            <p><spring:message code="${messageKey}" /></p>
		        </c:when>
		        <c:when test="${not empty message}">
		            <p><c:out value="${message}" escapeXml="true" /></p>
		        </c:when>
		    </c:choose>
		</div>
	</div>
</div>
<jsp:directive.include file="/WEB-INF/view/jsp/passport/ui/includes/bottom.jsp" />
